#ifndef QTUNITY3D_H
#define QTUNITY3D_H
#define  WIN32_LEAN_AND_MEAN

#include <QDate>
#include <QtWidgets/QMainWindow>
#include "ui_qtunity3d.h"
#include "QProcess"
#ifdef USE_UNITY3D
#include <windows.h>
#endif
class RoadTerrian;
class RoadGroup;
class OgreWidget;
typedef SharedPointer<RoadTerrian> PRoadTerrian;
typedef SharedPointer<RoadGroup> PRoadGroup;
class QActionGroup;
class qtUnity3d : public QMainWindow
{
	Q_OBJECT
public slots:
	void  on_cmdApply_clicked(bool bVal);
	void  on_cmdCreateBox_clicked(bool bVal);
	void  on_menu_wire_triggered(bool checked);
	void  on_menu_solid_triggered(bool checked);
	void  on_menu_seltime_triggered(bool checked);
	
private slots:
	void  On_Sel_Change(const ZMString& strObjName);
private:
#ifdef USE_UNITY3D
	signals :
	void signSelChange(const QString& strObjName);
#endif
public:
	qtUnity3d(QWidget *parent = 0);
	~qtUnity3d();

#ifdef USE_UNITY3D
	HWND GetHwndUnity3d() const { return m_hwndUnity3d; }

	void SetHwndUnity3d(HWND val) { m_hwndUnity3d = val; }

	void SelChange(const QString& strObjName)
	{
		emit signSelChange(strObjName);
	}
#endif

	QTreeView *  GetAtttibuteTree();

	OgreWidget* GetMain3dWindow();

	PRoadGroup GetRoadGroup();
	QDate GetCurentTime() const { return m_curentTime; }

	void SetCurentTime(QDate val) { m_curentTime = val; }
protected:
	void resizeEvent(QResizeEvent* event);

	void showEvent(QShowEvent *event);

	void hideEvent(QHideEvent *event);

	void mousePressEvent(QMouseEvent *event);

	void changeEvent(QEvent *event);

	void UpdateUIForSelChange();

	void UpdateData();
private:
#ifdef USE_UNITY3D
	static  BOOL CALLBACK FindWindow(HWND hwnd, LPARAM pHwnd);

	 void ActivateUnityWindow();

	 void DeactivateUnityWindow();
#endif
private slots:
	void Init();

private:
	Ui::qtUnity3dClass ui;
#ifdef USE_UNITY3D
	SharedPointer<QProcess> m_pPro;
	HWND m_hwndUnity3d;
#endif
	QString m_curSelObjName;
	PRoadTerrian m_pTerrian;
	PRoadGroup m_pvRoad;
	OgreWidget * m_OgreWidget;
	QActionGroup* m_groupAction;
	QDate m_curentTime;
};

#endif // QTUNITY3D_H
